import axios from 'axios';

const instance = axios.create({
  baseURL: 'http://localhost:5000', // Flask 默认端口
  timeout: 5000,
});

export const login = (data) => instance.post('/login', data);
export const getTaskList = (params) => instance.get('/get_task_list', { params });
export const showTaskLog = (taskId) => instance.get('/show_task_log', { params: { task_id: taskId } });
export const downloadTaskLog = (taskId) => instance.get('/download_task_log', { params: { task_id: taskId } });
export const getJobList = (params) => instance.get('/get_job_list', { params });
export const runJob = (jobId) => instance.post('/run_job', { job_id: jobId });
export const abortJob = (jobId) => instance.post('/abort_job', { job_id: jobId });
export const getWorkerNodes = (params) => instance.get('/get_worker_nodes', { params });
export const enableWorkerNode = (workerId, isEnable) =>
  instance.post('/enable_worker_node', { worker_id: workerId, is_enable: isEnable });
export const submitJob = (formData) =>
  instance.post('/submit_job', formData, { headers: { 'Content-Type': 'multipart/form-data' } });
export const getRegisterUrl = () => instance.get('/get_register_url');
export const getUserList = (params) => instance.get('/get_user_list', { params });
